define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		//编辑
		function get_data_assistenteEdit(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"member_id": "001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//数据
		function get_data_detail(result) {
			if(false) {
				result = '{"success":true,"msg":"","result":{"member_id":"001","phone":"12345789","mail":"1234@qq.com","name":"李某某","password":"a123456","part_id":"00121"},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//显示角色
		function get_data_partList(result) {
			if(false) {
				result = '{"success": false,"msg": "","result": {"role": [' +
					'{"id": "001","name": "售前客服"},' +
					'{"id": "002","name": "售后客服"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//验证手机号码
		function get_data_namecheck(result) {
			if(false) {
				result = '';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//返回信息
		return {
			//新增
			assistente_edit: function(member_id, phone, password, mail, name, part_id, callback) {
				var params = new Object();
				params.member_id = member_id;
				params.phone = phone;
				params.password = password;
				params.mail = mail;
				params.name = name;
				params.part_id = part_id;
				//				console.log(params)
				params = JSON.stringify(params);
				Http.post({
					method: 'member.assistente.edit',
					updateParams: params		
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_assistenteEdit(result));
				}, function(e) {

				}, function() {

				});
			},
			//修改
			modify: function(member_id, part_id, callback) {
				var params = new Object();
				params.member_id = member_id;
				params.part_id = part_id;
				params = JSON.stringify(params);
				Http.post({
					method: 'member.assistente.edit',
					updateParams: params
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_assistenteEdit(result));
				}, function(e) {

				}, function() {

				});
			},

			//根据id查找
			assistente_detail: function(member_id, callback) {
				Http.post({
					method: 'member.assistente.detail',
					member_id: member_id
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_detail(result));
				}, function(e) {

				}, function() {

				});

			},

			//我的店员角色一览===下拉
			part_list: function(callback) {
				//post请求
				Http.post({
					method: 'member.assistente.partlist',
					pagelimit: 50
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_partList(result).result);
				}, function(e) {

				}, function() {

				});
			},
			//验证手机号码
			namecheck: function(phone,callback) {
				//post请求
				Http.post({
					method: 'member.assistente.namecheck',
					phone: phone
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_namecheck(result));
				}, function(e) {

				}, function() {

				});
			},

		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Employeemanager_add", factory);
});